package com.ding.mongodb.dao.impl;

import com.ding.mongodb.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

public class UserRepositoryImpl {

	@Autowired
    MongoOperations mongo;
	
	public void updatePassword(String username,String newPassWord){

		mongo.updateFirst(
				Query.query(Criteria.where("username").is(username)),
				Update.update("password", newPassWord),
				User.class
		);

	}

}
